import {request} from 'umi';
import {useState} from "react";

/**
 * 获取正在录制的进程
 */
export const loadRecording = (server: string) => {
    return request(`${server}/record/recording`);
};

/**
 * 开始录制
 * @param server
 * @param inputSourceName 输入源进程名称
 * @param outputSourceName 输出源进程名称
 */
export const startRecord = (
    server: string,
    inputSourceName?: string,
    outputSourceName?: string,
) => {
    return request(`${server}/record/startRecord`, {
        data: {inputSourceName, outputSourceName},
        method: 'post',
    });
};

/**
 * 停止录制
 * @param server
 * @param inputSourceName 输入源进程名称
 * @param outputSourceName 输出源进程名称
 */
export const stopRecord = (
    server: string,
    inputSourceName?: string,
    outputSourceName?: string,
) => {
    return request(`${server}/record/stopRecord`, {
        data: {inputSourceName, outputSourceName},
        method: 'post',
    });
};
export const findDirs = (server: string, sourceName: string) => {
    return request(`${server}/record/findDirs`, {
        params: {sourceName},
    });
};

/**
 * 新增录制视频
 */
export const addVideo = (server: string, data: any) => {
    return request(`${server}/api/videoPlayback/addVideo`, {
        data: data,
        method: 'post',
    });
};

/**
 * 录制结束添加分片视频
 */
export const scanSegmentRecord = (server: string, id: string) => {
    return request(`${server}/api/videoPlayback/scanSegmentRecord?id=` + id, {
        method: 'get',
    });
};
